home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume89 / aplictns / plplot.6 < prev    next >
Internet Message Format  |  1989-04-25  |  65KB

  1. Path: xanth!indri!ames!oliveb!sun!rishathra!page
  2. From: page%rishathra@Sun.COM (Bob Page)
  3. Newsgroups: comp.sources.amiga
  4. Subject: v89i091:  plplot - scientific plotting library, Part06/07
  5. Message-ID: <100943@sun.Eng.Sun.COM>
  6. Date: 25 Apr 89 05:47:05 GMT
  7. Sender: news@sun.Eng.Sun.COM
  8. Lines: 2234
  9. Approved: page@sun.com
  10.  
  11. Submitted-by: amr@dukee.egr.duke.edu (Tony Richardson)
  12. Posting-number: Volume 89, Issue 91
  13. Archive-name: applications/plplot
  14.  
  15. # This is a shell archive.
  16. # Remove anything above and including the cut line.
  17. # Then run the rest of the file through 'sh'.
  18. # Unpacked files will be owned by you and have default permissions.
  19. #----cut here-----cut here-----cut here-----cut here----#
  20. #!/bin/sh
  21. # shar: SHell ARchive
  22. # Run the following text through 'sh' to create:
  23. #    plbeg.c
  24. #    plbin.c
  25. #    plbox.c
  26. #    plbox3.c
  27. #    plccal.c
  28. #    plclr.c
  29. #    plcntr.c
  30. #    plcol.c
  31. #    plcont.c
  32. #    plcvec.c
  33. #    pldeco.c
  34. #    pldtik.c
  35. #    plend.c
  36. #    plenv.c
  37. #    plerrx.c
  38. #    plerry.c
  39. #    plerx1.c
  40. #    plery1.c
  41. #    plfont.c
  42. #    plform.c
  43. #    plgra.c
  44. #    plgrid3.c
  45. #    plgspa.c
  46. #    plhist.c
  47. #    plhrsh.c
  48. #    pljoin.c
  49. #    pllab.c
  50. #    pllclp.c
  51. #    plline.c
  52. #    plmtex.c
  53. #    plnxtv.c
  54. # This is archive 6 of a 7-part kit.
  55. # This archive created: Thu Apr 20 13:47:05 1989
  56. echo "extracting plbeg.c"
  57. sed 's/^X//' << \SHAR_EOF > plbeg.c
  58. X/* Sets up the device "dev" for plotting, dividing the page into "nx" */
  59. X/* by "ny" subpages. */
  60. X
  61. X#include "plplot.h"
  62. X#include <math.h>
  63. X
  64. Xvoid plbeg(dev,nx,ny)      
  65. Xint dev, nx, ny;
  66. X{
  67. X      float scale, def, ht;
  68. X
  69. X      if ((nx <= 0) || (ny <= 0 )) 
  70. X         fatal("Cannot have negative number of subpages in PLSTAR");
  71. X
  72. X      scale = 1.0/sqrt((double)ny);
  73. X      grbeg(dev); 
  74. X      ssub(nx,ny,0);
  75. X
  76. X      /* Set up character, symbol and tick sizes for requested number of */
  77. X      /* subpages */
  78. X
  79. X      gchr(&def,&ht);
  80. X      schr(def*scale,def*scale);
  81. X      gsym(&def,&ht);
  82. X      ssym(def*scale,def*scale);
  83. X      gmaj(&def,&ht);
  84. X      smaj(def*scale,def*scale);
  85. X      gmin(&def,&ht);
  86. X      smin(def*scale,def*scale);
  87. X      slev(1);
  88. X}
  89. SHAR_EOF
  90. echo "extracting plbin.c"
  91. sed 's/^X//' << \SHAR_EOF > plbin.c
  92. X/* Plot a histogram using the arrays x and y to represent data       */
  93. X/* values and frequencies respectively. If centre is false, x values     */
  94. X/* denote the lower edge of the bin, and if centre is true, they        */
  95. X/* they denote the centre of the bin                                */
  96. X
  97. X#include "plplot.h"
  98. X#include <math.h>
  99. X
  100. Xvoid plbin(nbin,x,y,centre)
  101. Xint nbin;
  102. Xint centre;
  103. Xfloat x[], y[];
  104. X{
  105. X
  106. X      int i;
  107. X      float xmin, xmax, vpwxmi, vpwxma, vpwymi, vpwyma;
  108. X
  109. X      int level;
  110. X      glev(&level);
  111. X      if (level<3)fatal("Please set up window before calling PLBIN.");
  112. X
  113. X/*    Check x[i] are in ascending order */
  114. X
  115. X      for(i=0;i<nbin-1;i++)
  116. X        if (x[i] >= x[i+1])
  117. X           fatal("Elements of X(*) must be increasing in PLBIN.");
  118. X
  119. X      gvpw(&vpwxmi,&vpwxma,&vpwymi,&vpwyma);
  120. X      if (!centre) {
  121. X        for(i=0;i<nbin;i++){
  122. X          pljoin(x[i],vpwymi,x[i],y[i]);
  123. X          pljoin(x[i],y[i],x[i+1],y[i]);
  124. X          pljoin(x[i+1],y[i],x[i+1],vpwymi);
  125. X        }
  126. X        if (x[nbin-1] < vpwxma) {
  127. X          pljoin(x[nbin-1],vpwymi,x[nbin-1],y[nbin-1]);
  128. X          pljoin(x[nbin-1],y[nbin-1],vpwxma,y[nbin-1]);
  129. X          pljoin(vpwxma,y[nbin-1],vpwxma,vpwymi);
  130. X        }
  131. X      }
  132. X      else {
  133. X        if (nbin < 2) return;
  134. X        xmin = vpwxmi;
  135. X        xmax = max(0.5*(x[1]+x[2]),vpwxmi);
  136. X        if (xmin < xmax) {
  137. X          pljoin(xmin,vpwymi,xmin,y[1]);
  138. X          pljoin(xmin,y[1],xmax,y[1]);
  139. X          pljoin(xmax,y[1],xmax,vpwymi);
  140. X        }
  141. X        for (i=1;i<nbin-1;i++) {
  142. X          xmin = xmax;
  143. X          xmax = min(0.5*(x[i]+x[i+1]),vpwxma);
  144. X          pljoin(xmin,vpwymi,xmin,y[i]);
  145. X          pljoin(xmin,y[i],xmax,y[i]);
  146. X          pljoin(xmax,y[i],xmax,vpwymi);
  147. X        }
  148. X        xmin = xmax;
  149. X        xmax = vpwxma;
  150. X        if (xmin < xmax) {
  151. X          pljoin(xmin,vpwymi,xmin,y[nbin]);
  152. X          pljoin(xmin,y[nbin],xmax,y[nbin]);
  153. X          pljoin(xmax,y[nbin],xmax,vpwymi);
  154. X        }
  155. X      }
  156. X}
  157. SHAR_EOF
  158. echo "extracting plbox.c"
  159. sed 's/^X//' << \SHAR_EOF > plbox.c
  160. X/* This draws a box around the current viewport. XOPT and YOPT are */
  161. X/* character strings which define the box as follows: */
  162. X
  163. X/* A: Draw axis (X is horizontal line Y=0, Y is vertical line X=0) */
  164. X/* B: Draw bottom (X) or left (Y) edge of frame */
  165. X/* C: Draw top (X) or right (Y) edge of frame */
  166. X/* G: Draws a grid at the major tick interval */
  167. X/* I: Inverts tick marks */
  168. X/* L: Logarithmic axes, major ticks at decades, minor ticks at units */
  169. X/* N: Write numeric label at conventional location */
  170. X/* M: Write numeric label at unconventional location */
  171. X/* T: Draw major tick marks */
  172. X/* S: Draw minor tick marks */
  173. X/* V: (for Y only) Label vertically */
  174. X
  175. X/* xtick, ytick are the major tick intervals required, zero for  */
  176. X/*              automatic selection */
  177. X/* nxsub, nysub are the number of subtick intervals in a major tick */
  178. X/*              interval */
  179. X
  180. X#include "plplot.h"
  181. X#include <stdio.h>
  182. X#include <math.h>
  183. X#include <string.h>
  184. X
  185. X#define betw(c,a,b) ((a<=c && c<=b) || (b<=c && c<=a))
  186. X
  187. Xstatic float xlog[8] = {0.301030, 0.477121, 0.602060, 0.698970,
  188. X                        0.778151, 0.845098, 0.903090, 0.954243};
  189. X
  190. Xvoid plbox(xopt,xtick,nxsub,yopt,ytick,nysub)
  191. Xchar xopt[],yopt[];
  192. Xfloat xtick, ytick;
  193. Xint nxsub, nysub;
  194. X{
  195. X      char string[40];
  196. X      char strtmp[4];
  197. X      int lax,lbx,lcx,lgx,lix,llx,lmx,lnx,lsx,ltx;
  198. X      int lay,lby,lcy,lgy,liy,lly,lmy,lny,lsy,lty,lvy;
  199. X      int xmajor, xminor, ymajor, yminor, xmode, xprec;
  200. X      int ymode, yprec;
  201. X      int i, i1x, i2x, i3x, i4x, i1y, i2y, i3y, i4y, it0;
  202. X      int nxsub1, nysub1;
  203. X      int lxmin, lxmax, lymin, lymax;
  204. X      int pxmin, pxmax, pymin, pymax;
  205. X      int vppxmi, vppxma, vppymi, vppyma;
  206. X      int level;
  207. X      float xpmm, ypmm, defmaj, defmin, htmaj, htmin;
  208. X      float xtick1, ytick1, vpwxmi, vpwxma, vpwymi, vpwyma;
  209. X      float pos, tn, tp, temp;
  210. X
  211. X      glev(&level);
  212. X      if (level<3) fatal("Please set up window before calling PLBOX.");
  213. X
  214. X/* Open  the clip limits to the subpage limits */
  215. X
  216. X      gclp(&lxmin,&lxmax,&lymin,&lymax);
  217. X      gphy(&pxmin,&pxmax,&pymin,&pymax);
  218. X      sclp(pxmin,pxmax,pymin,pymax);
  219. X
  220. X      gvpp(&vppxmi,&vppxma,&vppymi,&vppyma);
  221. X
  222. X/* Tick and subtick sizes in device coords */
  223. X
  224. X      gpixmm(&xpmm,&ypmm);
  225. X      gmaj(&defmaj,&htmaj);
  226. X      gmin(&defmin,&htmin);
  227. X      
  228. X      xmajor=max(round(htmaj*ypmm),1);
  229. X      ymajor=max(round(htmaj*xpmm),1);
  230. X      xminor=max(round(htmin*ypmm),1);
  231. X      yminor=max(round(htmin*xpmm),1);
  232. X
  233. X      xtick1=xtick;
  234. X      nxsub1=nxsub;
  235. X      ytick1=ytick;
  236. X      nysub1=nysub;
  237. X
  238. X      lax=strpos(xopt,'A')!=-1 || strpos(xopt,'a')!=-1;
  239. X      lbx=strpos(xopt,'B')!=-1 || strpos(xopt,'b')!=-1;
  240. X      lcx=strpos(xopt,'C')!=-1 || strpos(xopt,'c')!=-1;
  241. X      lgx=strpos(xopt,'G')!=-1 || strpos(xopt,'g')!=-1;
  242. X      lix=strpos(xopt,'I')!=-1 || strpos(xopt,'i')!=-1;
  243. X      llx=strpos(xopt,'L')!=-1 || strpos(xopt,'l')!=-1;
  244. X      lmx=strpos(xopt,'M')!=-1 || strpos(xopt,'m')!=-1;
  245. X      lnx=strpos(xopt,'N')!=-1 || strpos(xopt,'n')!=-1;
  246. X      lsx=strpos(xopt,'S')!=-1 || strpos(xopt,'s')!=-1;
  247. X      ltx=strpos(xopt,'T')!=-1 || strpos(xopt,'t')!=-1;
  248. X
  249. X      lay=strpos(yopt,'A')!=-1 || strpos(yopt,'a')!=-1;
  250. X      lby=strpos(yopt,'B')!=-1 || strpos(yopt,'b')!=-1;
  251. X      lcy=strpos(yopt,'C')!=-1 || strpos(yopt,'c')!=-1;
  252. X      lgy=strpos(yopt,'G')!=-1 || strpos(yopt,'g')!=-1;
  253. X      liy=strpos(yopt,'I')!=-1 || strpos(yopt,'i')!=-1;
  254. X      lly=strpos(yopt,'L')!=-1 || strpos(yopt,'l')!=-1;
  255. X      lmy=strpos(yopt,'M')!=-1 || strpos(yopt,'m')!=-1;
  256. X      lny=strpos(yopt,'N')!=-1 || strpos(yopt,'n')!=-1;
  257. X      lsy=strpos(yopt,'S')!=-1 || strpos(yopt,'s')!=-1;
  258. X      lty=strpos(yopt,'T')!=-1 || strpos(yopt,'t')!=-1;
  259. X      lvy=strpos(yopt,'V')!=-1 || strpos(yopt,'v')!=-1;
  260. X
  261. X      gvpw(&vpwxmi,&vpwxma,&vpwymi,&vpwyma);
  262. X      lax=lax && (vpwymi*vpwyma<0.0) && !llx;
  263. X      lay=lay && (vpwxmi*vpwxma<0.0) && !lly;
  264. X      if (llx) xtick1=1.0;
  265. X      if (lly) ytick1=1.0;
  266. X      if (ltx || lgx) 
  267. X          pldtik(vpwxmi,vpwxma,&xtick1,&nxsub1,&xmode,&xprec);
  268. X      if (lty || lgy) 
  269. X          pldtik(vpwymi,vpwyma,&ytick1,&nysub1,&ymode,&yprec);
  270. X
  271. X/* Set up tick variables */
  272. X
  273. X      if (lix) {
  274. X        i1x=xminor;
  275. X        i2x=0;
  276. X        i3x=xmajor;
  277. X        i4x=0;
  278. X      }
  279. X      else {
  280. X        i1x=0;
  281. X        i2x=xminor;
  282. X        i3x=0;
  283. X        i4x=xmajor;
  284. X      }
  285. X
  286. X      if (liy) {
  287. X        i1y=yminor;
  288. X        i2y=0;
  289. X        i3y=ymajor;
  290. X        i4y=0;
  291. X      }
  292. X      else {
  293. X        i1y=0;
  294. X        i2y=yminor;
  295. X        i3y=0;
  296. X        i4y=ymajor;
  297. X      }
  298. X
  299. X/* Draw the bottom edge of the box */
  300. X
  301. X      if (lbx) {
  302. X        movphy(vppxmi,vppymi);
  303. X        if (ltx) {
  304. X          tp=xtick1*floor(vpwxmi/xtick1);
  305. Xbedge:
  306. X          tn=tp+xtick1;
  307. X          if (lsx) {
  308. X            if (llx) {
  309. X              for(i=0; i<=7;i++){
  310. X                temp=tp+xlog[i];
  311. X                if (betw(temp,vpwxmi,vpwxma))
  312. X                     plxtik(wcpcx(temp),vppymi,i1x,i2x);
  313. X              }
  314. X            }
  315. X            else {
  316. X              for ( i=1;i<=nxsub1-1;i++) {
  317. X                temp=tp+i*(tn-tp)/nxsub1;
  318. X                if (betw(temp,vpwxmi,vpwxma))
  319. X                     plxtik(wcpcx(temp),vppymi,i1x,i2x);
  320. X              }
  321. X            }
  322. X          }
  323. X          temp=tn;
  324. X          if (betw(temp,vpwxmi,vpwxma)) {
  325. X            plxtik(wcpcx(temp),vppymi,i3x,i4x);
  326. X            tp=tn;
  327. X            goto bedge;
  328. X          }
  329. X        }
  330. X        draphy(vppxma,vppymi);
  331. X      }
  332. X                                           
  333. X/* Draw right-hand edge of box */
  334. X
  335. X      if (lcy) {
  336. X        movphy(vppxma,vppymi);
  337. X        if (lty) {
  338. X          tp=ytick1*floor(vpwymi/ytick1);
  339. Xredge:
  340. X          tn=tp+ytick1;
  341. X          if (lsy) {
  342. X            if (lly) {
  343. X              for(i=0;i<=7;i++) {
  344. X                temp=tp+xlog[i];
  345. X                if (betw(temp,vpwymi,vpwyma))
  346. X                     plytik(vppxma,wcpcy(temp),i2y,i1y);
  347. X              }
  348. X            }
  349. X            else {
  350. X              for(i=1;i<=nysub1-1;i++) {
  351. X                temp=tp+i*(tn-tp)/nysub1;
  352. X                if (betw(temp,vpwymi,vpwyma))
  353. X                     plytik(vppxma,wcpcy(temp),i2y,i1y);
  354. X              }
  355. X            }
  356. X          }
  357. X          temp=tn;
  358. X          if (betw(temp,vpwymi,vpwyma)) {
  359. X            plytik(vppxma,wcpcy(temp),i4y,i3y);
  360. X            tp=tn;
  361. X            goto redge;
  362. X          }
  363. X        }
  364. X        draphy(vppxma,vppyma);
  365. X      }
  366. X
  367. X/* Draw the top edge of the box */
  368. X
  369. X      if (lcx) {
  370. X        movphy(vppxma,vppyma);
  371. X        if (ltx) {
  372. X          tp=xtick1*(floor(vpwxma/xtick1)+1);
  373. Xtedge:
  374. X          tn=tp-xtick1;
  375. X          if (lsx) {
  376. X            if (llx) {
  377. X              for(i=7;i>=0;i--) {
  378. X                temp=tn+xlog[i];
  379. X                if (betw(temp,vpwxmi,vpwxma))
  380. X                     plxtik(wcpcx(temp),vppyma,i2x,i1x);
  381. X              }
  382. X            }
  383. X            else {
  384. X              for(i=nxsub1-1;i>=1;i--) {
  385. X                temp=tn+i*(tp-tn)/nxsub1;
  386. X                if (betw(temp,vpwxmi,vpwxma))
  387. X                     plxtik(wcpcx(temp),vppyma,i2x,i1x);
  388. X              }
  389. X            }
  390. X          }
  391. X          temp=tn;
  392. X          if (betw(temp,vpwxmi,vpwxma)) {
  393. X            plxtik(wcpcx(temp),vppyma,i4x,i3x);
  394. X            tp=tn;
  395. X            goto tedge;
  396. X          }
  397. X        }
  398. X        draphy(vppxmi,vppyma);
  399. X      }
  400. X
  401. X/* Draw left-hand edge of box */
  402. X
  403. X      if (lby) {
  404. X        movphy(vppxmi,vppyma);
  405. X        if (lty) {
  406. X          tp=ytick1*(floor(vpwyma/ytick1)+1);
  407. Xledge:
  408. X          tn=tp-ytick1;
  409. X          if (lsy) {
  410. X            if (lly) {
  411. X              for(i=7;i>=0;i--) {
  412. X                temp=tn+xlog[i];
  413. X                if (betw(temp,vpwymi,vpwyma))
  414. X                     plytik(vppxmi,wcpcy(temp),i1y,i2y);
  415. X              }
  416. X            }
  417. X            else {
  418. X              for(i=nysub1-1;i>=1;i--) {
  419. X                temp=tn+i*(tp-tn)/nysub1;
  420. X                if (betw(temp,vpwymi,vpwyma))
  421. X                     plytik(vppxmi,wcpcy(temp),i1y,i2y);
  422. X              }
  423. X            }
  424. X          }
  425. X          temp=tn;
  426. X          if (betw(temp,vpwymi,vpwyma)) {
  427. X            plytik(vppxmi,wcpcy(temp),i3y,i4y);
  428. X            tp=tn;
  429. X            goto ledge;
  430. X          }
  431. X        }
  432. X        draphy(vppxmi,vppymi);
  433. X      }
  434. X
  435. X/* Draw the horizontal axis */
  436. X
  437. X      if (lax) {
  438. X        it0=wcpcy(0.0);
  439. X        movphy(vppxmi,it0);
  440. X        if (ltx) {
  441. X          tp=xtick1*floor(vpwxmi/xtick1);
  442. Xhaxis:
  443. X          tn=tp+xtick1;
  444. X          if (lsx) {
  445. X            if (llx) {
  446. X              for(i=0;i<=7;i++) {
  447. X                temp=tp+xlog[i];
  448. X                if (betw(temp,vpwxmi,vpwxma))
  449. X                     plxtik(wcpcx(temp),it0,xminor,xminor);
  450. X              }
  451. X            }
  452. X            else {
  453. X              for(i=1;i<=nxsub1-1;i++) {
  454. X                temp=tp+i*(tn-tp)/nxsub1;
  455. X                if (betw(temp,vpwxmi,vpwxma))
  456. X                     plxtik(wcpcx(temp),it0,xminor,xminor);
  457. X              }
  458. X            }
  459. X          }
  460. X          temp=tn;
  461. X          if (betw(temp,vpwxmi,vpwxma)) {
  462. X            plxtik(wcpcx(temp),it0,xmajor,xmajor);
  463. X            tp=tn;
  464. X            goto haxis;
  465. X          }
  466. X        }
  467. X        draphy(vppxma,it0);
  468. X      }
  469. X
  470. X/* Draw the vertical axis */
  471. X
  472. X      if (lay) {
  473. X        it0=wcpcx(0.0);
  474. X        movphy(it0,vppymi);
  475. X        if (lty) {
  476. X          tp=ytick1*floor(vpwymi/ytick1);
  477. Xvaxis:
  478. X          tn=tp+ytick1;
  479. X          if (lsy) {
  480. X            if (lly) {
  481. X              for(i=0;i<=7;i++) {
  482. X                temp=tp+xlog[i];
  483. X                if (betw(temp,vpwymi,vpwyma))
  484. X                   plytik(it0,wcpcy(temp),yminor,yminor);
  485. X              }
  486. X            }
  487. X            else {
  488. X              for(i=1;i<=nysub1-1;i++) {
  489. X                temp=tp+i*(tn-tp)/nysub1;
  490. X                if (betw(temp,vpwymi,vpwyma))
  491. X                     plytik(it0,wcpcy(temp),yminor,yminor);
  492. X              }
  493. X            }
  494. X          }
  495. X          temp=tn;
  496. X          if (betw(temp,vpwymi,vpwyma)) {
  497. X            plytik(it0,wcpcy(temp),ymajor,ymajor);
  498. X            tp=tn;
  499. X            goto vaxis;
  500. X          }
  501. X        }
  502. X        draphy(it0,vppyma);
  503. X      }
  504. X
  505. X/* Draw grid in x direction */
  506. X
  507. X      if (lgx) {
  508. X        tp=xtick1*floor(vpwxmi/xtick1);
  509. Xxgrid:
  510. X          tn=tp+xtick1;
  511. X          if (betw(tn,vpwxmi,vpwxma)) {
  512. X            pljoin(tn,vpwymi,tn,vpwyma);
  513. X            tp=tn;
  514. X            goto xgrid;
  515. X          }
  516. X      }
  517. X
  518. X/* Draw grid in y direction */
  519. X
  520. X      if (lgy) {
  521. X        tp=ytick1*floor(vpwymi/ytick1);
  522. Xygrid:
  523. X          tn=tp+ytick1;
  524. X          if (betw(tn,vpwymi,vpwyma)) {
  525. X            pljoin(vpwxmi,tn,vpwxma,tn);
  526. X            tp=tn;
  527. X            goto ygrid;
  528. X          }
  529. X      }
  530. X
  531. X/* Write horizontal label(s) */
  532. X      if ((lmx || lnx) && ltx) {
  533. X        tp=xtick1*floor(vpwxmi/xtick1);
  534. Xhlabel:
  535. X        tn=tp+xtick1;
  536. X        if (betw(tn,vpwxmi,vpwxma)) {
  537. X          if (!llx)
  538. X            plform(tn,xmode,xprec,string);
  539. X          else {
  540. X            sprintf(strtmp,"%-d",round(tn));
  541. X            strcpy(string,"10\\u");
  542. X            strcat(string,strtmp);
  543. X          }
  544. X          pos=(tn-vpwxmi)/(vpwxma-vpwxmi);
  545. X          if (lnx) plmtex("b",1.5,pos,0.5,string);
  546. X          if (lmx) plmtex("t",1.5,pos,0.5,string);
  547. X          tp=tn;
  548. X          goto hlabel;
  549. X        }
  550. X      }
  551. X
  552. X/* Write vertical label(s) */
  553. X      if ((lmy || lny) && lty) {
  554. X        tp=ytick1*floor(vpwymi/ytick1);
  555. Xvlabel:
  556. X        tn=tp+ytick1             ;
  557. X        if (betw(tn,vpwymi,vpwyma)) {
  558. X          if (!lly) 
  559. X            plform(tn,ymode,yprec,string);
  560. X          else {
  561. X            sprintf(strtmp,"%-d",round(tn));
  562. X            strcpy(string,"10\\u");
  563. X            strcat(string,strtmp);
  564. X          }
  565. X          pos=(tn-vpwymi)/(vpwyma-vpwymi);
  566. X          if (lny) {
  567. X            if (lvy)
  568. X              plmtex("lv",0.5,pos,1.0,string);
  569. X            else
  570. X              plmtex("l",1.5,pos,0.5,string);
  571. X          }
  572. X          if (lmy) {
  573. X            if (lvy) 
  574. X              plmtex("rv",0.5,pos,0.0,string);
  575. X            else
  576. X              plmtex("r",1.5,pos,0.5,string);
  577. X          }
  578. X          tp=tn;
  579. X          goto vlabel;
  580. X        }
  581. X      }
  582. X
  583. X/* Restore the clip limits to viewport edge */
  584. X
  585. X      sclp(lxmin,lxmax,lymin,lymax);
  586. X}
  587. SHAR_EOF
  588. echo "extracting plbox3.c"
  589. sed 's/^X//' << \SHAR_EOF > plbox3.c
  590. X/* Draws axes and axis labels for 3-d plots */
  591. X
  592. X#include "plplot.h"
  593. X
  594. Xvoid plbox3(xopt,xlabel,xtick,nsubx,yopt,ylabel,ytick,nsuby,
  595. X            zopt,zlabel,ztick,nsubz)
  596. Xchar *xopt, *xlabel, *yopt, *ylabel, *zopt, *zlabel;
  597. Xint nsubx, nsuby, nsubz;
  598. Xfloat xtick, ytick, ztick;
  599. X{      
  600. X      float dx,dy,tx,ty,ux,uy;
  601. X      float xmin,xmax,ymin,ymax,zmin,zmax,zscale;
  602. X      float cxx,cxy,cyx,cyy,cyz;
  603. X      int ln;
  604. X
  605. X      int level;
  606. X      glev(&level);
  607. X      if (level < 3) fatal("Please set up window before calling PLBOX3");
  608. X
  609. X      gw3wc(&cxx,&cxy,&cyx,&cyy,&cyz);
  610. X      gdom(&xmin,&xmax,&ymin,&ymax);
  611. X      grange(&zscale,&zmin,&zmax);
  612. X
  613. X      if (cxx >= 0.0 && cxy <= 0.0) {
  614. X        ln=strpos(xopt,'N') != -1 || strpos(xopt,'n') != -1;
  615. X        tx=w3wcx(xmin,ymin,zmin);
  616. X        ty=w3wcy(xmin,ymin,zmin);
  617. X        ux=w3wcx(xmax,ymin,zmin);
  618. X        uy=w3wcy(xmax,ymin,zmin);
  619. X        plxybx(xopt,xlabel,tx,ty,ux,uy,xmin,xmax,xtick,nsubx,0);
  620. X        dx = ux - tx;
  621. X        dy = uy - ty;
  622. X        plzbx(zopt,zlabel,1,dx,dy,ux,uy,
  623. X             w3wcy(xmax,ymin,zmax),zmin,zmax,ztick,nsubz);
  624. X        tx=w3wcx(xmin,ymax,zmin);
  625. X        ty=w3wcy(xmin,ymax,zmin);
  626. X        ux=w3wcx(xmin,ymin,zmin);
  627. X        uy=w3wcy(xmin,ymin,zmin);
  628. X        plxybx(yopt,ylabel,tx,ty,ux,uy,ymax,ymin,ytick,nsuby,ln);
  629. X        dx = ux - tx;
  630. X        dy = uy - ty;
  631. X        plzbx(zopt,zlabel,0,dx,dy,tx,ty,
  632. X             w3wcy(xmin,ymax,zmax),zmin,zmax,ztick,nsubz);
  633. X
  634. X      }
  635. X      else if (cxx <= 0.0 && cxy <= 0.0) {
  636. X        ln=strpos(yopt,'N') != -1 || strpos(yopt,'n') != -1;
  637. X        tx=w3wcx(xmin,ymax,zmin);
  638. X        ty=w3wcy(xmin,ymax,zmin);
  639. X        ux=w3wcx(xmin,ymin,zmin);
  640. X        uy=w3wcy(xmin,ymin,zmin);
  641. X        plxybx(yopt,ylabel,tx,ty,ux,uy,ymax,ymin,ytick,nsuby,0);
  642. X        dx = ux - tx;
  643. X        dy = uy - ty;
  644. X        plzbx(zopt,zlabel,1,dx,dy,ux,uy,
  645. X             w3wcy(xmin,ymin,zmax),zmin,zmax,ztick,nsubz);
  646. X        tx=w3wcx(xmax,ymax,zmin);
  647. X        ty=w3wcy(xmax,ymax,zmin);
  648. X        ux=w3wcx(xmin,ymax,zmin);
  649. X        uy=w3wcy(xmin,ymax,zmin);
  650. X        plxybx(xopt,xlabel,tx,ty,ux,uy,xmax,xmin,xtick,nsubx,ln);
  651. X        dx = ux - tx;
  652. X        dy = uy - ty;
  653. X        plzbx(zopt,zlabel,0,dx,dy,tx,ty,
  654. X             w3wcy(xmax,ymax,zmax),zmin,zmax,ztick,nsubz);
  655. X
  656. X      }
  657. X      else if (cxx <= 0.0 && cxy >= 0.0) {
  658. X        ln=strpos(xopt,'N') != -1 || strpos(xopt,'n') != -1;
  659. X        tx=w3wcx(xmax,ymax,zmin);
  660. X        ty=w3wcy(xmax,ymax,zmin);
  661. X        ux=w3wcx(xmin,ymax,zmin);
  662. X        uy=w3wcy(xmin,ymax,zmin);
  663. X        plxybx(xopt,xlabel,tx,ty,ux,uy,xmax,xmin,xtick,nsubx,0);
  664. X        dx = ux - tx;
  665. X        dy = uy - ty;
  666. X        plzbx(zopt,zlabel,1,dx,dy,ux,uy,
  667. X             w3wcy(xmin,ymax,zmax),zmin,zmax,ztick,nsubz);
  668. X        tx=w3wcx(xmax,ymin,zmin);
  669. X        ty=w3wcy(xmax,ymin,zmin);
  670. X        ux=w3wcx(xmax,ymax,zmin);
  671. X        uy=w3wcy(xmax,ymax,zmin);
  672. X        plxybx(yopt,ylabel,tx,ty,ux,uy,ymin,ymax,ytick,nsuby,ln);
  673. X        dx = ux - tx;
  674. X        dy = uy - ty;
  675. X        plzbx(zopt,zlabel,0,dx,dy,tx,ty,
  676. X             w3wcy(xmax,ymin,zmax),zmin,zmax,ztick,nsubz);
  677. X      }
  678. X      else if (cxx >= 0.0 && cxy >= 0.0) {
  679. X        ln=strpos(yopt,'N') != -1 || strpos(yopt,'n') != -1;
  680. X        tx=w3wcx(xmax,ymin,zmin);
  681. X        ty=w3wcy(xmax,ymin,zmin);
  682. X        ux=w3wcx(xmax,ymax,zmin);
  683. X        uy=w3wcy(xmax,ymax,zmin);
  684. X        plxybx(yopt,ylabel,tx,ty,ux,uy,ymin,ymax,ytick,nsuby,0);
  685. X        dx = ux - tx;
  686. X        dy = uy - ty;
  687. X        plzbx(zopt,zlabel,1,dx,dy,ux,uy,
  688. X             w3wcy(xmax,ymax,zmax),zmin,zmax,ztick,nsubz);
  689. X        tx=w3wcx(xmin,ymin,zmin);
  690. X        ty=w3wcy(xmin,ymin,zmin);
  691. X        ux=w3wcx(xmax,ymin,zmin);
  692. X        uy=w3wcy(xmax,ymin,zmin);
  693. X        plxybx(xopt,xlabel,tx,ty,ux,uy,xmin,xmax,xtick,nsubx,ln);
  694. X        dx = ux - tx;
  695. X        dy = uy - ty;
  696. X        plzbx(zopt,zlabel,0,dx,dy,tx,ty,
  697. X             w3wcy(xmin,ymin,zmax),zmin,zmax,ztick,nsubz);
  698. X
  699. X      }
  700. X}
  701. X
  702. SHAR_EOF
  703. echo "extracting plccal.c"
  704. sed 's/^X//' << \SHAR_EOF > plccal.c
  705. X/* Subroutine to interpolate the position of a contour which is known */
  706. X/* to be next to ix,iy in the direction ixg,iyg. The unscaled distance */
  707. X/* along ixg,iyg is returned as dist */
  708. X
  709. X#include "plplot.h"
  710. X
  711. Xvoid plccal(pts,nx,ny,zlev,ix,iy,ixg,iyg,dist)
  712. Xint nx,ny,ix,iy,ixg,iyg;
  713. Xfloat *pts,zlev,*dist;
  714. X{
  715. X      int ia,ib;
  716. X      float dbot, dtop, pmid, qmid, zmid;
  717. X
  718. X      ia = ix+ixg;
  719. X      ib = iy+iyg;
  720. X      if (ixg == 0 || iyg == 0) {
  721. X        dtop = zlev - *(pts+(ix-1)*ny+iy-1);
  722. X        dbot = *(pts+(ia-1)*ny+ib-1) - *(pts+(ix-1)*ny+iy-1);
  723. X        *dist = 0.0;
  724. X        if (dbot != 0.0) *dist = dtop/dbot;
  725. X      }
  726. X      else {
  727. X        pmid = *(pts+(ix-1)*ny+iy-1) + *(pts+(ia-1)*ny+ib-1);
  728. X        qmid = *(pts+(ix-1)*ny+ib-1) + *(pts+(ia-1)*ny+iy-1);
  729. X        zmid = (pmid+qmid)/4.0;
  730. X        if (zmid >= zlev) {
  731. X          dtop = zlev - *(pts+(ix-1)*ny+iy-1);
  732. X          dbot = zmid - *(pts+(ix-1)*ny+iy-1);
  733. X          *dist = 0.0;
  734. X          if (dbot != 0.0) *dist = 0.5*dtop/dbot;
  735. X        }
  736. X        else {
  737. X          dtop = zlev-zmid;
  738. X          dbot = *(pts+(ia-1)*ny+ib-1) - zmid;
  739. X          *dist = 0.5;
  740. X          if (dbot != 0.0) *dist = 0.5 + 0.5*dtop/dbot;
  741. X        }
  742. X      }
  743. X}
  744. SHAR_EOF
  745. echo "extracting plclr.c"
  746. sed 's/^X//' << \SHAR_EOF > plclr.c
  747. X#include "plplot.h"
  748. X
  749. Xvoid plclr()
  750. X{
  751. X      int level;
  752. X      glev(&level);
  753. X      if (level < 1) fatal("Please call PLSTAR before calling PLCLR.");
  754. X
  755. X      grclr();
  756. X}
  757. SHAR_EOF
  758. echo "extracting plcntr.c"
  759. sed 's/^X//' << \SHAR_EOF > plcntr.c
  760. X/* Contour "ny" by "nx" real array "points" at the level "zlev" */
  761. X/* points is a pointer to a 2d array of nx by ny points. */
  762. X/* iscan has nx elements. ixstor and iystor each have nstor elements. */
  763. X
  764. X#include "plplot.h"
  765. X
  766. Xvoid plcntr(points,nx,ny,kx,lx,ky,ly,zlev,iscan,ixstor,iystor,nstor,tr)
  767. Xint nx, ny, ky, ly, kx, lx, nstor;
  768. Xfloat zlev, *points;
  769. Xint iscan[], ixstor[], iystor[];
  770. Xvoid (*tr)();
  771. X{
  772. X      int kcol, krow, kstor, kscan, iwbeg, ixbeg, iybeg, izbeg;
  773. X      int iboun, iw, ix, iy, iz, ifirst, istep, ixgo, iygo;
  774. X      int l, ixg, iyg, ia, ib, ixt, iyt, jstor, next;
  775. X      float dist, dx, dy, xnew, ynew, x, y;
  776. X      float xlas=0., ylas=0., tpx, tpy, xt, yt;
  777. X
  778. X      /* Initialize memory pointers */
  779. X
  780. X      kstor = 0;
  781. X      kscan = 0;
  782. X
  783. X      for (krow=ky; krow<=ly; krow++) {
  784. X        for (kcol=kx+1; kcol <= lx; kcol++)  {
  785. X
  786. X          /* Check if a contour has been crossed */
  787. X
  788. X          x = *(points + (kcol-2)*ny + krow-1);
  789. X          y = *(points + (kcol-1)*ny + krow-1);
  790. X          if (x < zlev && y >= zlev) {
  791. X            ixbeg = kcol-1;
  792. X            iwbeg = kcol;
  793. X          }
  794. X          else if (y < zlev && x >= zlev) {
  795. X            ixbeg = kcol;
  796. X            iwbeg = kcol-1;
  797. X          }
  798. X          else
  799. X            goto lab70;
  800. X
  801. X          iybeg = krow;
  802. X          izbeg = krow;
  803. X
  804. X          /* Yes, a contour has been crossed. Check to see if it */
  805. X          /* is a new one. */
  806. X
  807. X          for(l=0;l<kscan;l++)
  808. X            if (ixbeg == iscan[l]) goto lab70;
  809. X
  810. X          /* Here is the section which follows and draws a contour */
  811. X
  812. X          for (iboun=1; iboun>= -1; iboun -= 2) {
  813. X
  814. X            /* Set up starting point and initial search directions */
  815. X
  816. X            ix = ixbeg;
  817. X            iy = iybeg;
  818. X            iw = iwbeg;
  819. X            iz = izbeg;
  820. X            ifirst = 1;
  821. X            istep = 0;
  822. X            ixgo = iw - ix;
  823. X            iygo = iz - iy;
  824. X
  825. Xlab20:
  826. X              plccal(points,nx,ny,zlev,ix,iy,ixgo,iygo,&dist);
  827. X              dx = dist * ixgo;
  828. X              dy = dist * iygo;
  829. X              xnew = ix+dx;
  830. X              ynew = iy+dy;
  831. X
  832. X             /* Has a step occured in search? */
  833. X
  834. X              if (istep != 0) {
  835. X                if (ixgo*iygo == 0) {
  836. X
  837. X                  /* This was a diagonal step, so interpolate missed */
  838. X                  /* point, rotating 45 degrees to get it */
  839. X
  840. X                  ixg = ixgo;
  841. X                  iyg = iygo;
  842. X                  plr45(&ixg,&iyg,iboun);
  843. X                  ia = iw-ixg;
  844. X                  ib = iz-iyg;
  845. X                  plccal(points,nx,ny,zlev,ia,ib,ixg,iyg,&dist);
  846. X                  (*tr)(xlas,ylas,&tpx,&tpy);
  847. X                  drawor(tpx,tpy);
  848. X                  dx = dist*ixg;
  849. X                  dy = dist*iyg;
  850. X                  xlas = ia+dx;
  851. X                  ylas = ib+dy;
  852. X                }
  853. X                else {
  854. X                  if (dist > 0.5) {
  855. X                    xt = xlas;
  856. X                    xlas = xnew;
  857. X                    xnew = xt;
  858. X                    yt = ylas;
  859. X                    ylas = ynew;
  860. X                    ynew = yt;
  861. X                  }
  862. X                }
  863. X              }
  864. X              if (ifirst != 1) {
  865. X                (*tr)(xlas,ylas,&tpx,&tpy);
  866. X                drawor(tpx,tpy);
  867. X              }
  868. X              else {
  869. X                (*tr)(xnew,ynew,&tpx,&tpy);
  870. X                movwor(tpx,tpy);
  871. X              }
  872. X              xlas = xnew;
  873. X              ylas = ynew;
  874. X
  875. X              /* Check if the contour is closed */
  876. X
  877. X              if (ifirst != 1 && ix == ixbeg && iy == iybeg
  878. X                  && iw == iwbeg && iz == izbeg) {
  879. X                (*tr)(xlas,ylas,&tpx,&tpy);
  880. X                drawor(tpx,tpy);
  881. X                goto lab70;
  882. X              }
  883. X              ifirst = 0;
  884. X
  885. X              /* Now the rotation */
  886. X
  887. X              istep = 0;
  888. X              plr45(&ixgo,&iygo,iboun);
  889. X              iw = ix+ixgo;
  890. X              iz = iy+iygo;
  891. X
  892. X              /* Check if out of bounds */
  893. X
  894. X              if (iw<kx || iw>lx || iz<ky || iz>ly) goto  lab50;
  895. X
  896. X              /* Has contact been lost with the contour? */
  897. X
  898. X              if (*(points+(iw-1)*ny+iz-1) < zlev) {
  899. X
  900. X                /* Yes, lost contact => step to new centre */
  901. X
  902. X                istep = 1;
  903. X                ix = iw;
  904. X                iy = iz;
  905. X                plr135(&ixgo,&iygo,iboun);
  906. X                iw = ix+ixgo;
  907. X                iz = iy+iygo;
  908. X
  909. X                /* And do the contour memory */
  910. X
  911. X                if (iy == krow) {
  912. X                  kscan = kscan+1;
  913. X                  iscan[kscan-1] = ix;
  914. X                }
  915. X                else if (iy>krow) {
  916. X                  kstor = kstor+1;
  917. X                  if (kstor>nstor) {
  918. X                    fatal("Heap exhausted in PLCONT.");
  919. X                    goto lab70;
  920. X                  }
  921. X                  ixstor[kstor-1] = ix;
  922. X                  iystor[kstor-1] = iy;
  923. X                }
  924. X              }
  925. X            goto lab20;
  926. Xlab50:
  927. X            /* Reach here only if boundary encountered - Draw last bit */
  928. X
  929. X            (*tr)(xnew,ynew,&tpx,&tpy);
  930. X            drawor(tpx,tpy);
  931. X          }
  932. Xlab70:
  933. X          ;    /* Null statement to carry label */
  934. X        }
  935. X
  936. X        /* Search of row complete - set up memory of next row in iscan and */
  937. X        /* edit ixstor and iystor */
  938. X
  939. X        if (krow<ny) {
  940. X          jstor = 0;
  941. X          kscan = 0;
  942. X          next = krow+1;
  943. X          for (l=1; l<=kstor; l++) {
  944. X            ixt = ixstor[l-1];
  945. X            iyt = iystor[l-1];
  946. X
  947. X            /* Memory of next row into iscan */
  948. X
  949. X            if (iyt == next) {
  950. X              kscan = kscan+1;
  951. X              iscan[kscan-1] = ixt;
  952. X      
  953. X            /* Retain memory of rows to come, and forget rest */
  954. X
  955. X            }
  956. X            else if (iyt>next) {
  957. X              jstor = jstor+1;
  958. X              ixstor[jstor-1] = ixt;
  959. X              iystor[jstor-1] = iyt;
  960. X            }
  961. X          }
  962. X          kstor = jstor;
  963. X        }
  964. X      }
  965. X}
  966. SHAR_EOF
  967. echo "extracting plcol.c"
  968. sed 's/^X//' << \SHAR_EOF > plcol.c
  969. X/* Sets line colour */
  970. X
  971. X#include "plplot.h"
  972. X
  973. Xvoid plcol(colour)
  974. Xint colour;
  975. X{
  976. X      int font,col;
  977. X
  978. X      int level;
  979. X      glev(&level);
  980. X      if (level < 1)  fatal("Please call PLSTAR before calling PLCOL.");
  981. X      if (colour < 0)  fatal("Invalid colour in PLCOL.");
  982. X
  983. X      gatt(&font,&col);
  984. X      satt(font,colour);
  985. X      grcol();
  986. X}
  987. SHAR_EOF
  988. echo "extracting plcont.c"
  989. sed 's/^X//' << \SHAR_EOF > plcont.c
  990. X/* Draws a contour plot from data in z(nx,ny), using the subarray */
  991. X/* from kx to lx in the x direction and from ky to ly in the y */
  992. X/* direction. The array of contour levels is clevel(nlevel), and */
  993. X/* "tr" is the name of a subroutine which transforms array indicies */
  994. X/* into world coordinates */
  995. X
  996. X#include <stdio.h>
  997. X#include <stdlib.h>
  998. X#include "plplot.h"
  999. X#include "declare.h"
  1000. X
  1001. Xvoid plcont(z,nx,ny,kx,lx,ky,ly,clevel,nlevel,tr)
  1002. Xint nx, ny, kx, lx, ky, ly, nlevel;
  1003. Xfloat *z, clevel[];
  1004. Xvoid (*tr)();
  1005. X{
  1006. X      int i, mx, my, nstor;
  1007. X
  1008. X      mx = lx - kx + 1;
  1009. X      my = ly - ky + 1;
  1010. X
  1011. X      if (kx < 1 || lx > nx || kx >= lx || ky < 1 || ky > ny || ky >= ly)
  1012. X               fatal("Argument error in PLCONT");
  1013. X      
  1014. X      nstor = mx*my/5;
  1015. X
  1016. X      if( heapc != NULL)
  1017. X         free(heapc);
  1018. X      if(( heapc = (int *)malloc((mx+2*nstor)*sizeof(int))) == NULL)
  1019. X         fatal("Not enough heap space in PLCONT.");
  1020. X
  1021. X      for (i=0; i<nlevel; i++)
  1022. X        plcntr(z,nx,ny,kx,lx,ky,ly,clevel[i],&heapc[0],
  1023. X               &heapc[nx],&heapc[nx+nstor],nstor,tr);
  1024. X
  1025. X}
  1026. SHAR_EOF
  1027. echo "extracting plcvec.c"
  1028. sed 's/^X//' << \SHAR_EOF > plcvec.c
  1029. X/* Gets the character digitisation of Hershey table entry "char" */
  1030. X/* Returns 1 if there is a valid entry */
  1031. X
  1032. Xextern short int *buffer[];
  1033. Xextern int *findex[];
  1034. X
  1035. X#include "plplot.h"
  1036. X
  1037. Xint plcvec(ch,xygrid)
  1038. Xint ch;
  1039. Xshort int xygrid[];
  1040. X{
  1041. X
  1042. X      int nc1, nc2, k, ib, ix, iy;
  1043. X
  1044. X      nc1=1;
  1045. X      nc2=3000;
  1046. X      if (ch < nc1 || ch > nc2) return(0);
  1047. X      ib = *(findex[(ch-nc1)/100] + (ch-nc1)%100);
  1048. X      if (ib == 0) return(0);
  1049. X
  1050. X      k=1;
  1051. X      xygrid[k-1]= *(buffer[(ib-1)/100] + (ib-1)%100);
  1052. X
  1053. X      k=k+1;
  1054. X      do {
  1055. X        ib=ib+1;
  1056. X        ix= *(buffer[(ib-1)/100]+(ib-1)%100)/128 - 64;
  1057. X        xygrid[k-1]=ix;
  1058. X        k=k+1;
  1059. X        iy = *(buffer[(ib-1)/100]+(ib-1)%100)%128 - 64;
  1060. X        xygrid[k-1]=iy;
  1061. X        k=k+1;
  1062. X      } while (ix != -64 || iy != -64);
  1063. X
  1064. X      return(1);
  1065. X
  1066. X} 
  1067. SHAR_EOF
  1068. echo "extracting pldeco.c"
  1069. sed 's/^X//' << \SHAR_EOF > pldeco.c
  1070. X/* Decode a character string, and return an array of integer symbol */
  1071. X/* numbers. This routine is responsible for interpreting all escape */
  1072. X/* sequences. At present the following escape sequences are defined */
  1073. X/* (the letter following the \ may be either upper or lower case): */
  1074. X
  1075. X/* \u       :      up one level (returns -1) */
  1076. X/* \d       :      down one level (returns -2) */
  1077. X/* \b       :      backspace (returns -3) */
  1078. X/* \+       :      toggles overline mode (returns -4) */
  1079. X/* \-       :      toggles underline mode (returns -5) */
  1080. X/* \\       :      \, returns the code for backslash */
  1081. X/* \gx      :      greek letter corresponding to roman letter x */
  1082. X/* \fn      :      switch to Normal font */
  1083. X/* \fr      :      switch to Roman font */
  1084. X/* \fi      :      switch to Italic font */
  1085. X/* \fs      :      switch to Script font */
  1086. X/* \(nnn)   :      Hershey symbol number nnn (any number of digits) */
  1087. X
  1088. X#include "plplot.h"
  1089. X#include <stdio.h>    /* include for definition of NULL */
  1090. X#include <string.h>
  1091. X
  1092. Xstatic char font[] = "nrisnris";
  1093. Xstatic char greek[] = "ABGDEZYHIKLMNCOPRSTUFXQWabgdezyhiklmncoprstufxqw";
  1094. X
  1095. Xextern short int *hersh[];
  1096. X
  1097. Xvoid pldeco(symbol,length,text)
  1098. Xint symbol[],*length;
  1099. Xchar text[];
  1100. X{
  1101. X      int ch,icol,ifont,ig,j,lentxt;
  1102. X      char test;
  1103. X
  1104. X      /* Initialize parameters. */
  1105. X
  1106. X      lentxt=strlen(text);
  1107. X      *length=0;
  1108. X      j=0;
  1109. X      gatt(&ifont,&icol);
  1110. X
  1111. X      /* Get next character; treat non-printing characters as spaces. */
  1112. X
  1113. Xlab100:
  1114. X      j=j+1;
  1115. X      if (j>lentxt) return;
  1116. X      test=text[j-1];
  1117. X      ch=test;
  1118. X      if (ch<0)   ch = 32;
  1119. X
  1120. X      if (ch>175) ch = 32;
  1121. X
  1122. X      /* Test for escape sequence (\) */
  1123. X
  1124. X      if (ch=='\\') {
  1125. X        if ((lentxt-j)>=1) {
  1126. X          test=text[j];
  1127. X          if (test=='\\')
  1128. X            j = j+1;
  1129. X          else if (test=='U' || test=='u') {
  1130. X            *length = *length + 1;
  1131. X            symbol[*length-1] = -1;
  1132. X            j = j+1;
  1133. X            goto lab100;
  1134. X          }
  1135. X          else if (test=='D' || test=='d') {
  1136. X            *length = *length + 1;
  1137. X            symbol[*length-1] = -2;
  1138. X            j = j+1;
  1139. X            goto lab100;
  1140. X          }
  1141. X          else if (test=='B' || test=='b') {
  1142. X            *length = *length + 1;
  1143. X            symbol[*length-1] = -3;
  1144. X            j = j+1;
  1145. X            goto lab100;
  1146. X          }
  1147. X          else if (test=='+') {
  1148. X            *length = *length + 1;
  1149. X            symbol[*length-1] = -4;
  1150. X            j = j+1;
  1151. X            goto lab100;
  1152. X          }
  1153. X          else if (test=='-') {
  1154. X            *length = *length + 1;
  1155. X            symbol[*length-1] = -5;
  1156. X            j = j+1;
  1157. X            goto lab100;
  1158. X          }
  1159. X          else if (test=='(') {
  1160. X            *length = *length + 1;
  1161. X            symbol[*length-1] = 0;
  1162. X            j = j+2;
  1163. Xlab10:
  1164. X            if ('0'<=text[j-1] && text[j-1]<='9') {
  1165. X              symbol[*length-1] = symbol[*length-1]*10 + text[j-1] - '0';
  1166. X              j = j+1;
  1167. X              goto lab10;
  1168. X            }
  1169. X            if (text[j-1]!=')') j = j-1;
  1170. X            goto lab100;
  1171. X          }
  1172. X          else if (test=='F' || test=='f') {
  1173. X            test=text[j+1];
  1174. X            ifont = strpos(font,test) + 1;
  1175. X            if (ifont>4) ifont = ifont-4;
  1176. X            if (ifont==0) ifont = 1;
  1177. X            j = j+2;
  1178. X            goto lab100;
  1179. X          }
  1180. X          else if (test=='G' || test=='g') {
  1181. X            test=text[j+1];
  1182. X            ig = strpos(greek,test) + 1;
  1183. X            *length = *length + 1;
  1184. X            symbol[*length-1] = *(hersh[ifont-1] + 127 + ig);
  1185. X            j = j+2;
  1186. X            goto lab100;
  1187. X          }
  1188. X        }
  1189. X      }
  1190. X
  1191. X      /* Decode character. */
  1192. X
  1193. X      *length = *length + 1;
  1194. X      symbol[*length-1] = *(hersh[ifont-1]+ch);
  1195. X      goto lab100;
  1196. X}
  1197. SHAR_EOF
  1198. echo "extracting pldtik.c"
  1199. sed 's/^X//' << \SHAR_EOF > pldtik.c
  1200. X/* If tick == 0, this works out a "nice" interval, so that there */
  1201. X/* are between 3 and 7.5 major tick intervals in the input range */
  1202. X/* "vmin" to "vmax". Using this value for the tick interval or   */
  1203. X/* supplied value, it also computes "prec" which specifies       */
  1204. X/* the number of places that should be written after the decimal */
  1205. X/* point. The recommended number of subticks is returned in      */
  1206. X/* "nsubt" unless the routine is entered with a non-zero value   */
  1207. X/* of "nsubt". The output variable "mode" is set to 0 if         */
  1208. X/* labels are to be written in floating-point format, or to 1 if */
  1209. X/* they are to be written in fixed-point format.                 */
  1210. X                                                                
  1211. X#include "plplot.h"
  1212. X#include <math.h>
  1213. X
  1214. Xvoid pldtik(vmin, vmax, tick, nsubt, mode, prec)
  1215. Xfloat vmin, vmax, *tick;
  1216. Xint *nsubt, *mode, *prec;
  1217. X{
  1218. X      
  1219. X      float t1, t2, vmod;
  1220. X      int msd, np, ns;
  1221. X
  1222. X      vmod = max(fabs(vmin),fabs(vmax));
  1223. X      *mode = 0;
  1224. X      if (vmod < 1.0e-2 || vmod > 1.0e6) *mode = 1;
  1225. X      t1 = (float)log10(vmod);
  1226. X      msd = (int)t1;
  1227. X
  1228. X      t1 = (float)log10(fabs(vmax-vmin));
  1229. X      np = (int)t1;
  1230. X      t1 = t1 - np;
  1231. X      
  1232. X      if (t1 > 0.7781512503) {
  1233. X        t2 = 2.0 ;
  1234. X        ns = 4;
  1235. X      }
  1236. X      else if (t1 > 0.4771212549) {
  1237. X        t2 = 1.0 ;
  1238. X        ns = 5;
  1239. X      }
  1240. X      else if (t1 > 0.1760912591) {
  1241. X        t2 = 5.0;
  1242. X        ns = 5;
  1243. X        np = np-1;
  1244. X      }
  1245. X      else  {
  1246. X        t2 = 2.0;
  1247. X        ns = 4;
  1248. X        np = np-1;
  1249. X      }
  1250. X
  1251. X      if (*tick == 0.0) {
  1252. X        *tick = t2 * pow(10.0,(double)np);
  1253. X        if (vmin > vmax) *tick = -*tick;
  1254. X        if (*nsubt == 0) *nsubt = ns;
  1255. X        if (*mode != 0) 
  1256. X          *prec = msd - np;
  1257. X        else
  1258. X          *prec = max(-np,0);
  1259. X      }
  1260. X      else  {
  1261. X        t1 = (float)log10(fabs(*tick));
  1262. X        np = (int)t1;
  1263. X        if (*mode != 0) 
  1264. X          *prec = msd - np + 1;
  1265. X        else
  1266. X          *prec = max(-np+1,0);
  1267. X      }
  1268. X}
  1269. X
  1270. SHAR_EOF
  1271. echo "extracting plend.c"
  1272. sed 's/^X//' << \SHAR_EOF > plend.c
  1273. X/* Ends a plotting session */
  1274. X
  1275. X#include <stdio.h>
  1276. X#include <stdlib.h>
  1277. X#include "plplot.h"
  1278. X#include "declare.h"
  1279. X
  1280. Xvoid plend()
  1281. X{
  1282. X      int dev, term, gra, level;
  1283. X      
  1284. X      glev(&level);
  1285. X      if (level == 0) return;
  1286. X      gdev(&dev,&term,&gra);
  1287. X      if( heap3 != NULL) free((void *)heap3);
  1288. X      if( heapc != NULL) free((void *)heapc);
  1289. X      if (gra != 0) pltext();
  1290. X      grtidy();
  1291. X      slev(0);
  1292. X}
  1293. SHAR_EOF
  1294. echo "extracting plenv.c"
  1295. sed 's/^X//' << \SHAR_EOF > plenv.c
  1296. X/* Simple interface for defining viewport and window. If "just"=1,  */
  1297. X/* X and Y scales will be the same, otherwise they are scaled       */
  1298. X/* independently. The "axis" parameter is interpreted as follows:   */
  1299. X/* axis=-2 : draw no box, axis or labels                            */
  1300. X/* axis=-1 : draw box only                                          */
  1301. X/* axis= 0 : Draw box and label with coordinates                    */
  1302. X/* axis= 1 : Also draw the coordinate axes                          */
  1303. X/* axis= 2 : Draw a grid at major tick positions                    */
  1304. X/* axis=10 : Logarithmic X axis, L!=r Y axis, No X=0 axis         */
  1305. X/* axis=11 : Logarithmic X axis, L!=r Y axis, X=0 axis            */
  1306. X/* axis=20 : L!=r X axis, Logarithmic Y axis, No Y=0 axis         */
  1307. X/* axis=21 : L!=r X axis, Logarithmic Y axis, Y=0 axis            */
  1308. X/* axis=30 : Logarithmic X and Y axes                               */
  1309. X
  1310. X#include "plplot.h"
  1311. X#include <math.h>
  1312. X
  1313. Xvoid plenv(xmin,xmax,ymin,ymax,just,axis)
  1314. Xint just,axis;
  1315. Xfloat xmin, xmax, ymin, ymax;
  1316. X{
  1317. X    int level;
  1318. X    float chrdef, chrht;
  1319. X    float lb, rb, tb, bb, dx, dy;
  1320. X    float xsize, ysize, xscale, yscale;
  1321. X    float spxmin, spxmax, spymin, spymax;
  1322. X    float vpxmin, vpxmax, vpymin, vpymax;
  1323. X    float scale;
  1324. X
  1325. X    glev(&level);
  1326. X    if (level < 1) fatal("Please call PLSTAR before PLENV.");
  1327. X    
  1328. X    if (xmin == xmax) fatal("Invalid xmin and xmax arguments in PLENV");
  1329. X    if (ymin == ymax) fatal("Invalid ymin and ymax arguments in PLENV");
  1330. X    if ((just != 0) && (just != 1)) fatal("Invalid just option in PLENV");
  1331. X
  1332. X
  1333. X    pladv(0);
  1334. X    if (just == 0)
  1335. X      plvsta();
  1336. X    else {
  1337. X      gchr(&chrdef,&chrht);
  1338. X      lb = 7.0 * chrht;
  1339. X      rb = 4.0 * chrht;
  1340. X      tb = 4.0 * chrht;
  1341. X      bb = 4.0 * chrht;
  1342. X      dx = fabs(xmax-xmin);
  1343. X      dy = fabs(ymax-ymin);
  1344. X      plgspa(&spxmin,&spxmax,&spymin,&spymax);
  1345. X      xsize = spxmax - spxmin;
  1346. X      ysize = spymax - spymin;
  1347. X      xscale = dx/(xsize - lb - rb);
  1348. X      yscale = dy/(ysize - tb - bb);
  1349. X      scale = max(xscale,yscale);
  1350. X      vpxmin = max(lb,0.5*(xsize - dx/scale));
  1351. X      vpxmax = vpxmin + (dx/scale);
  1352. X      vpymin = max(bb,0.5*(ysize - dy/scale));
  1353. X      vpymax = vpymin + (dy/scale);
  1354. X      plsvpa(vpxmin,vpxmax,vpymin,vpymax);
  1355. X    }
  1356. X    plwind(xmin,xmax,ymin,ymax);
  1357. X    if (axis == -2)
  1358. X       ;
  1359. X    else if (axis == -1)
  1360. X       plbox("bc",0.0,0,"bc",0.0,0);
  1361. X    else if (axis == 0) 
  1362. X       plbox("bcnst",0.0,0,"bcnstv",0.0,0);
  1363. X    else if (axis == 1) 
  1364. X       plbox("abcnst",0.0,0,"abcnstv",0.0,0);
  1365. X    else if (axis == 2) 
  1366. X       plbox("abcgnst",0.0,0,"abcgnstv",0.0,0);
  1367. X    else if (axis == 10) 
  1368. X       plbox("bclnst",0.0,0,"bcnstv",0.0,0);
  1369. X    else if (axis == 11) 
  1370. X       plbox("bclnst",0.0,0,"abcnstv",0.0,0);
  1371. X    else if (axis == 20) 
  1372. X       plbox("bcnst",0.0,0,"bclnstv",0.0,0);
  1373. X    else if (axis == 21) 
  1374. X       plbox("bcnst",0.0,0,"abclnstv",0.0,0);
  1375. X    else if (axis == 30) 
  1376. X       plbox("bclnst",0.0,0,"bclnstv",0.0,0);
  1377. X    else
  1378. X       fatal("Invalid axis argument in plenv");
  1379. X}
  1380. SHAR_EOF
  1381. echo "extracting plerrx.c"
  1382. sed 's/^X//' << \SHAR_EOF > plerrx.c
  1383. X/* Plots horizontal error bars (xmin(i),y(i)) to (xmax(i),y(i)) */
  1384. X
  1385. X#include "plplot.h"
  1386. X
  1387. Xvoid plerrx(n,xmin,xmax,y)
  1388. Xint n;
  1389. Xfloat xmin[], xmax[], y[];
  1390. X{
  1391. X      int i, level;
  1392. X
  1393. X      glev(&level);
  1394. X      if (level < 3) fatal("Please set up window before calling PLERRX.");
  1395. X      for (i=0;i<n;i++)
  1396. X        plerx1(xmin[i],xmax[i],y[i]);
  1397. X}
  1398. SHAR_EOF
  1399. echo "extracting plerry.c"
  1400. sed 's/^X//' << \SHAR_EOF > plerry.c
  1401. X/* Plots vertical error bars (x,ymin(i)) to (x(i),ymax(i)) */
  1402. X
  1403. X#include "plplot.h"
  1404. X
  1405. Xvoid plerry(n,x,ymin,ymax)
  1406. Xint n;
  1407. Xfloat x[], ymin[], ymax[];
  1408. X{
  1409. X      int i, level;
  1410. X
  1411. X      glev(&level);
  1412. X      if (level < 3) fatal("Please set up window before calling PLERRY.");
  1413. X      for(i=0; i<n; i++)
  1414. X        plery1(x[i],ymin[i],ymax[i]);
  1415. X}
  1416. SHAR_EOF
  1417. echo "extracting plerx1.c"
  1418. sed 's/^X//' << \SHAR_EOF > plerx1.c
  1419. X/* Plots single horizontal error bar */
  1420. X
  1421. X#include "plplot.h"
  1422. X#include <math.h>
  1423. X
  1424. Xvoid plerx1(xmin,xmax,y)
  1425. Xfloat xmin, xmax, y;
  1426. X{
  1427. X      float mindef, minht, xpmm, ypmm;
  1428. X      int yminor;
  1429. X      
  1430. X      gmin(&mindef,&minht);
  1431. X      gpixmm(&xpmm,&ypmm);
  1432. X      yminor = max(1.0,minht*ypmm);
  1433. X      movwor(xmin,y);
  1434. X      plxtik(wcpcx(xmin),wcpcy(y),yminor,yminor);
  1435. X      drawor(xmax,y);
  1436. X      plxtik(wcpcx(xmax),wcpcy(y),yminor,yminor);
  1437. X}
  1438. SHAR_EOF
  1439. echo "extracting plery1.c"
  1440. sed 's/^X//' << \SHAR_EOF > plery1.c
  1441. X/* Plots single vertical error bar */
  1442. X
  1443. X#include "plplot.h"
  1444. X#include <math.h>
  1445. X
  1446. Xvoid plery1(x,ymin,ymax)
  1447. Xfloat x, ymin, ymax;
  1448. X{
  1449. X      float mindef, minht, xpmm, ypmm;
  1450. X      int xminor;
  1451. X      
  1452. X      gmin(&mindef,&minht);
  1453. X      gpixmm(&xpmm,&ypmm);
  1454. X      xminor = max(1.0,minht*xpmm);
  1455. X      movwor(x,ymin);
  1456. X      plytik(wcpcx(x),wcpcy(ymin),xminor,xminor);
  1457. X      drawor(x,ymax);
  1458. X      plytik(wcpcx(x),wcpcy(ymax),xminor,xminor);
  1459. X}
  1460. SHAR_EOF
  1461. echo "extracting plfont.c"
  1462. sed 's/^X//' << \SHAR_EOF > plfont.c
  1463. X#include "plplot.h"
  1464. X
  1465. Xvoid plfont(ifont)
  1466. Xint ifont;
  1467. X{
  1468. X      int ifnt,icol;
  1469. X
  1470. X      int level;
  1471. X      glev(&level);
  1472. X      if (level < 1) fatal("Please call PLSTAR before calling PLFONT.");
  1473. X
  1474. X      if (ifont < 1 || ifont > 4) fatal("Invalid font in PLFONT");
  1475. X      gatt(&ifnt,&icol);
  1476. X      satt(ifont,icol);
  1477. X}
  1478. SHAR_EOF
  1479. echo "extracting plform.c"
  1480. sed 's/^X//' << \SHAR_EOF > plform.c
  1481. X/* Formats a floating point value in one of the following formats   */
  1482. X/* (i)  If mode == 0, use floating point format with "precision"    */
  1483. X/*      places after the decimal point.                             */
  1484. X/* (ii) If mode == 1, use scientific notation with one place before */
  1485. X/*      the decimal point and "precision" places after.             */
  1486. X
  1487. X#include "plplot.h"
  1488. X#include <stdio.h>
  1489. X#include <string.h>
  1490. X
  1491. Xvoid plform(value,mode,prec,result)
  1492. Xfloat value;
  1493. Xint mode, prec;
  1494. Xchar *result;
  1495. X{
  1496. X      int j, expon;
  1497. X      char form[10];
  1498. X      char temp[30];
  1499. X
  1500. X      if (mode == 0) {
  1501. X        sprintf(form,"%%-.%df",prec);
  1502. X        sprintf(temp,form,value);
  1503. X        strcpy(result,temp);
  1504. X      }
  1505. X      else {
  1506. X        sprintf(form,"%%-.%dE",prec);
  1507. X        sprintf(temp,form,value);
  1508. X        j = strpos(temp,'E') + 1;
  1509. X        if (j == 0) fatal("Unrecognized scientific notation");
  1510. X        sscanf(&temp[j],"%d",&expon);
  1511. X        sprintf(form,"%-d",expon);
  1512. X        strcpy(&temp[j-1],"x10\\u");
  1513. X        strcat(temp,form);
  1514. X        strcpy(result,temp);
  1515. X      }
  1516. X}
  1517. X
  1518. SHAR_EOF
  1519. echo "extracting plgra.c"
  1520. sed 's/^X//' << \SHAR_EOF > plgra.c
  1521. X/* Switches to graphics mode */
  1522. X
  1523. X#include "plplot.h"
  1524. X
  1525. Xvoid plgra()
  1526. X{
  1527. X      int level;
  1528. X      glev(&level);
  1529. X      if (level < 1) fatal("Please call PLSTAR before PLGRA.");
  1530. X      grgra();
  1531. X}
  1532. SHAR_EOF
  1533. echo "extracting plgrid3.c"
  1534. sed 's/^X//' << \SHAR_EOF > plgrid3.c
  1535. X/* Routine to draw a grid around the back side of the 3d plot */
  1536. X/* wih hidden line removal */
  1537. X
  1538. X#include "plplot.h"
  1539. X#include <math.h>
  1540. X
  1541. Xvoid plgrid3(tick)
  1542. Xfloat tick;
  1543. X{
  1544. X    float xmin, ymin, zmin, xmax, ymax, zmax, zscale;
  1545. X    float cxx, cxy, cyx, cyy, cyz;
  1546. X    int u[3], v[3];
  1547. X    int nsub, mode, prec;
  1548. X    float tp;
  1549. X
  1550. X    gw3wc(&cxx,&cxy,&cyx,&cyy,&cyz);
  1551. X    gdom(&xmin,&xmax,&ymin,&ymax);
  1552. X    grange(&zscale,&zmin,&zmax);
  1553. X
  1554. X    nsub = 0;
  1555. X    pldtik(zmin,zmax,&tick,&nsub,&mode,&prec);
  1556. X    tp = tick * floor(zmin/tick) + tick;
  1557. X
  1558. X    if (cxx >= 0.0 && cxy <= 0.0)  {
  1559. X        while ( tp <= zmax ) {
  1560. X            u[0] = wcpcx(w3wcx(xmin,ymax,tp));
  1561. X            v[0] = wcpcy(w3wcy(xmin,ymax,tp));
  1562. X            u[1] = wcpcx(w3wcx(xmax,ymax,tp));
  1563. X            v[1] = wcpcy(w3wcy(xmax,ymax,tp));
  1564. X            u[2] = wcpcx(w3wcx(xmax,ymin,tp));
  1565. X            v[2] = wcpcy(w3wcy(xmax,ymin,tp));
  1566. X            plnxtv(u,v,3,2);
  1567. X
  1568. X            tp += tick;
  1569. X        }
  1570. X        u[0] = wcpcx(w3wcx(xmax,ymax,zmin));
  1571. X        v[0] = wcpcy(w3wcy(xmax,ymax,zmin));
  1572. X        u[1] = wcpcx(w3wcx(xmax,ymax,zmax));
  1573. X        v[1] = wcpcy(w3wcy(xmax,ymax,zmax));
  1574. X        plnxtv(u,v,2,2);
  1575. X    }
  1576. X    else if(cxx <= 0.0  && cxy <= 0.0)  {
  1577. X        while ( tp <= zmax ) {
  1578. X            u[0] = wcpcx(w3wcx(xmax,ymax,tp));
  1579. X            v[0] = wcpcy(w3wcy(xmax,ymax,tp));
  1580. X            u[1] = wcpcx(w3wcx(xmax,ymin,tp));
  1581. X            v[1] = wcpcy(w3wcy(xmax,ymin,tp));
  1582. X            u[2] = wcpcx(w3wcx(xmin,ymin,tp));
  1583. X            v[2] = wcpcy(w3wcy(xmin,ymin,tp));
  1584. X            plnxtv(u,v,3,2);
  1585. X
  1586. X            tp += tick;
  1587. X        }
  1588. X        u[0] = wcpcx(w3wcx(xmax,ymin,zmin));
  1589. X        v[0] = wcpcy(w3wcy(xmax,ymin,zmin));
  1590. X        u[1] = wcpcx(w3wcx(xmax,ymin,zmax));
  1591. X        v[1] = wcpcy(w3wcy(xmax,ymin,zmax));
  1592. X        plnxtv(u,v,2,2);
  1593. X    }
  1594. X    else if(cxx <= 0.0  && cxy >= 0.0)  {
  1595. X        while ( tp <= zmax ) {
  1596. X            u[0] = wcpcx(w3wcx(xmax,ymin,tp));
  1597. X            v[0] = wcpcy(w3wcy(xmax,ymin,tp));
  1598. X            u[1] = wcpcx(w3wcx(xmin,ymin,tp));
  1599. X            v[1] = wcpcy(w3wcy(xmin,ymin,tp));
  1600. X            u[2] = wcpcx(w3wcx(xmin,ymax,tp));
  1601. X            v[2] = wcpcy(w3wcy(xmin,ymax,tp));
  1602. X            plnxtv(u,v,3,2);
  1603. X
  1604. X            tp += tick;
  1605. X        }
  1606. X        u[0] = wcpcx(w3wcx(xmin,ymin,zmin));
  1607. X        v[0] = wcpcy(w3wcy(xmin,ymin,zmin));
  1608. X        u[1] = wcpcx(w3wcx(xmin,ymin,zmax));
  1609. X        v[1] = wcpcy(w3wcy(xmin,ymin,zmax));
  1610. X        plnxtv(u,v,2,2);
  1611. X    }
  1612. X    else if(cxx >= 0.0  && cxy >= 0.0)  {
  1613. X        while ( tp <= zmax ) {
  1614. X            u[0] = wcpcx(w3wcx(xmin,ymin,tp));
  1615. X            v[0] = wcpcy(w3wcy(xmin,ymin,tp));
  1616. X            u[1] = wcpcx(w3wcx(xmin,ymax,tp));
  1617. X            v[1] = wcpcy(w3wcy(xmin,ymax,tp));
  1618. X            u[2] = wcpcx(w3wcx(xmax,ymax,tp));
  1619. X            v[2] = wcpcy(w3wcy(xmax,ymax,tp));
  1620. X            plnxtv(u,v,3,2);
  1621. X
  1622. X            tp += tick;
  1623. X        }
  1624. X        u[0] = wcpcx(w3wcx(xmin,ymax,zmin));
  1625. X        v[0] = wcpcy(w3wcy(xmin,ymax,zmin));
  1626. X        u[1] = wcpcx(w3wcx(xmin,ymax,zmax));
  1627. X        v[1] = wcpcy(w3wcy(xmin,ymax,zmax));
  1628. X        plnxtv(u,v,2,2);
  1629. X    }
  1630. X}
  1631. SHAR_EOF
  1632. echo "extracting plgspa.c"
  1633. sed 's/^X//' << \SHAR_EOF > plgspa.c
  1634. X/* Gets subpage boundaries in absolute coordinates (mm from bottom */
  1635. X/* left-hand corner of page) */
  1636. X
  1637. X#include "plplot.h"
  1638. X
  1639. Xvoid plgspa(xmin,xmax,ymin,ymax)
  1640. Xfloat *xmin, *xmax, *ymin, *ymax;
  1641. X{
  1642. X      float spdxmi, spdxma, spdymi, spdyma;
  1643. X
  1644. X      int level;
  1645. X
  1646. X      glev(&level);
  1647. X      if (level < 1) fatal("Please call PLSTAR before PLGSPA.");
  1648. X      gspd(&spdxmi,&spdxma,&spdymi,&spdyma);
  1649. X      *xmin = dcmmx(spdxmi);
  1650. X      *xmax = dcmmx(spdxma);
  1651. X      *ymin = dcmmy(spdymi);
  1652. X      *ymax = dcmmy(spdyma);
  1653. X}
  1654. SHAR_EOF
  1655. echo "extracting plhist.c"
  1656. sed 's/^X//' << \SHAR_EOF > plhist.c
  1657. X/* Draws a histogram of n values of a variable in array data(1..n) */
  1658. X/* in the range datmin to datmax using nbin bins. If "oldwin" is   */
  1659. X/* true, the histogram is plotted in the current window. If not,   */
  1660. X/* the routine calls "plenv" to set up the graphics environment.   */
  1661. X
  1662. X#include "plplot.h"
  1663. X#include <math.h>
  1664. X
  1665. Xvoid plhist(n,data,datmin,datmax,nbin,oldwin)
  1666. Xint n, nbin;
  1667. Xint oldwin;
  1668. Xfloat data[], datmin, datmax;
  1669. X{
  1670. X      int i, bin, level;
  1671. X      float x[201], y[201], dx, ymax;
  1672. X      
  1673. X      glev(&level);
  1674. X      if (level<1) fatal("Please call PLSTAR before PLHIST.");
  1675. X      if (level<3 && oldwin)
  1676. X              fatal("Please set up window before calling PLHIST.");
  1677. X      
  1678. X      if (nbin < 1 || nbin > 200)
  1679. X              fatal("Cannot have <1 or >200 bins in PLHIST.");
  1680. X      if (datmin >= datmax)
  1681. X              fatal("Data range invalid in PLHIST.");
  1682. X      
  1683. X      dx = (datmax-datmin) / nbin;
  1684. X      for (i=0; i<=nbin; i++) {
  1685. X        x[i] = datmin + i*dx;
  1686. X        y[i] = 0.0;
  1687. X      }
  1688. X
  1689. X      for (i=0; i<n; i++)  {
  1690. X        bin = (data[i] - datmin)/dx;
  1691. X        if (bin >= 0 && bin < nbin) y[bin]++;
  1692. X      }
  1693. X
  1694. X      if (!oldwin) {
  1695. X        ymax = 0.0;
  1696. X        for (i=0; i<nbin; i++) ymax = max(ymax,y[i]);
  1697. X        plenv(datmin,datmax,0.0,1.1*ymax,0,0);
  1698. X      }
  1699. X         
  1700. X      plbin(nbin+1,x,y,0);
  1701. X}
  1702. SHAR_EOF
  1703. echo "extracting plhrsh.c"
  1704. sed 's/^X//' << \SHAR_EOF > plhrsh.c
  1705. X/* Writes the Hershey symbol "ch" centred at the physical */
  1706. X/* coordinate (x,y) */
  1707. X
  1708. X#include "plplot.h"
  1709. X
  1710. Xvoid plhrsh(ch,x,y)
  1711. Xint ch, x, y;
  1712. X{
  1713. X      int cx, cy, k, penup;
  1714. X      short int xygrid[300];
  1715. X      float symdef, symht, scale, xscale, yscale, xpmm, ypmm;
  1716. X
  1717. X      gsym(&symdef,&symht);
  1718. X      gpixmm(&xpmm,&ypmm);
  1719. X      k = 5;
  1720. X      penup = 1;
  1721. X      scale = 0.05 * symht;
  1722. X
  1723. X      if (!plcvec(ch,xygrid)) {
  1724. X        movphy(x,y);
  1725. X        return;
  1726. X      }
  1727. X      
  1728. X      /* Compute how many physical pixels correspond to a character pixel */
  1729. X
  1730. X      xscale = scale * xpmm;
  1731. X      yscale = scale * ypmm;
  1732. X
  1733. X      for(;;) {
  1734. X        cx = xygrid[k];
  1735. X        k = k+1;
  1736. X        cy = xygrid[k];
  1737. X        k = k+1;
  1738. X        if (cx == -64 && cy == -64) {
  1739. X          movphy(x,y);
  1740. X          return;
  1741. X        }
  1742. X        else if (cx == -64 && cy == 0) 
  1743. X          penup = 1;
  1744. X        else  {
  1745. X          if (penup != 0) {
  1746. X            movphy(round(x+xscale*cx),round(y+yscale*cy));
  1747. X            penup = 0;
  1748. X          }
  1749. X          else
  1750. X            draphy(round(x+xscale*cx),round(y+yscale*cy));
  1751. X        }
  1752. X      }
  1753. X}
  1754. SHAR_EOF
  1755. echo "extracting pljoin.c"
  1756. sed 's/^X//' << \SHAR_EOF > pljoin.c
  1757. X#include "plplot.h"
  1758. X
  1759. Xvoid pljoin(x1,y1,x2,y2)
  1760. Xfloat x1, x2, y1, y2;
  1761. X{
  1762. X   movwor(x1,y1);
  1763. X   drawor(x2,y2);
  1764. X}
  1765. SHAR_EOF
  1766. echo "extracting pllab.c"
  1767. sed 's/^X//' << \SHAR_EOF > pllab.c
  1768. X/* Simple routine for labelling graphs */
  1769. X
  1770. X#include "plplot.h"
  1771. X
  1772. Xvoid pllab(xlabel, ylabel, tlabel)
  1773. Xchar *xlabel, *ylabel, *tlabel;
  1774. X{
  1775. X      int level;
  1776. X      glev(&level);
  1777. X      if (level < 2) fatal("Please set up viewport before calling PLLAB.");
  1778. X
  1779. X      plmtex("t",2.0,0.5,0.5,tlabel);
  1780. X      plmtex("b",3.2,0.5,0.5,xlabel);
  1781. X      plmtex("l",5.0,0.5,0.5,ylabel);
  1782. X}
  1783. SHAR_EOF
  1784. echo "extracting pllclp.c"
  1785. sed 's/^X//' << \SHAR_EOF > pllclp.c
  1786. X/* Draws a (x1,y1) to (x2,y2) within the clip limits */
  1787. X
  1788. X#include "plplot.h"
  1789. X
  1790. X#define betw(ix,ia,ib) ((ix<=ia && ix>=ib) || (ix>=ia && ix<=ib))
  1791. X#define inside(ix,iy) (betw(ix,clpxmi,clpxma) && betw(iy,clpymi,clpyma))
  1792. X#define ixcut(iy) round((float)((x2-x1)*(iy-y1)+x1*(y2-y1))/(float)(y2-y1))
  1793. X#define iycut(ix) round((float)((y2-y1)*(ix-x1)+y1*(x2-x1))/(float)(x2-x1))
  1794. X
  1795. Xvoid pllclp(x1,y1,x2,y2)
  1796. Xint x1,y1,x2,y2;
  1797. X{
  1798. X      int xt[2],yt[2];
  1799. X      int it, k;
  1800. X      int clpxmi,clpxma,clpymi,clpyma;
  1801. X
  1802. X      gclp(&clpxmi,&clpxma,&clpymi,&clpyma);
  1803. X      k=0;
  1804. X      if (inside(x1,y1)) {
  1805. X        xt[k]=x1;
  1806. X        yt[k]=y1;
  1807. X        k=k+1;
  1808. X      }
  1809. X      if (inside(x2,y2)) {
  1810. X        xt[k]=x2;
  1811. X        yt[k]=y2;
  1812. X        k=k+1;
  1813. X      }
  1814. X      if (k == 2) goto draw;
  1815. X      if (y1 != y2) {
  1816. X        it=ixcut(clpymi);
  1817. X        if (inside(it,clpymi) && betw(clpymi,y1,y2)) {
  1818. X          xt[k]=it;
  1819. X          yt[k]=clpymi;
  1820. X          k=k+1;
  1821. X        }
  1822. X        if (k == 2) goto draw;
  1823. X        it=ixcut(clpyma);
  1824. X        if (inside(it,clpyma) && betw(clpyma,y1,y2)) {
  1825. X          xt[k]=it;
  1826. X          yt[k]=clpyma;
  1827. X          k=k+1;
  1828. X        }
  1829. X        if (k == 2) goto draw;
  1830. X      }
  1831. X      if (x1 != x2) {
  1832. X        it=iycut(clpxmi);
  1833. X        if (inside(clpxmi,it) && betw(clpxmi,x1,x2)) {
  1834. X          xt[k]=clpxmi;
  1835. X          yt[k]=it;
  1836. X          k=k+1;
  1837. X        }
  1838. X        if (k == 2) goto draw;
  1839. X        it=iycut(clpxma);
  1840. X        if (inside(clpxma,it) && betw(clpxma,x1,x2)) {
  1841. X          xt[k]=clpxma;
  1842. X          yt[k]=it;
  1843. X          k=k+1;
  1844. X        }
  1845. X        if (k == 2) goto draw;
  1846. X      }
  1847. Xdraw:
  1848. X      if (k == 2) genlin(xt[0],yt[0],xt[1],yt[1]);
  1849. X      scurr(x2,y2);
  1850. X} 
  1851. SHAR_EOF
  1852. echo "extracting plline.c"
  1853. sed 's/^X//' << \SHAR_EOF > plline.c
  1854. X#include "plplot.h"
  1855. X
  1856. Xvoid plline(n,x,y)
  1857. Xint n;
  1858. Xfloat x[],y[];
  1859. X{
  1860. X      int i,level;
  1861. X      glev(&level);
  1862. X      if (level<3) fatal("Please set up window before calling PLLINE.");
  1863. X      movwor(x[0],y[0]);
  1864. X      for(i=0; i<n; i++)
  1865. X        drawor(x[i],y[i]);
  1866. X}
  1867. SHAR_EOF
  1868. echo "extracting plmtex.c"
  1869. sed 's/^X//' << \SHAR_EOF > plmtex.c
  1870. X/* Prints out "text" at specified position relative to viewport       */
  1871. X/* (may be inside or outside)                                         */
  1872. X
  1873. X/* side   String which is one of the following:                       */
  1874. X/*        B or b  :  Bottom of viewport                               */
  1875. X/*        T or t  :  Top of viewport                                  */
  1876. X/*        L or l  :  Left of viewport                                 */
  1877. X/*        R or r  :  Right of viewport                                */
  1878. X/*        LV or lv : Left of viewport, vertical text                  */
  1879. X/*        RV or rv : Right of viewport, vertical text                 */
  1880. X/* disp   Displacement from specified edge of viewport, measured      */
  1881. X/*         outwards from the viewport in units of the current         */
  1882. X/*         character height. The CENTRELINES of the characters are    */
  1883. X/*         aligned with the specified position.                       */
  1884. X/* pos    Position of the reference point of the string relative      */
  1885. X/*         to the viewport edge, ranging from 0.0 (left-hand edge)    */
  1886. X/*         to 1.0 (right-hand edge)                                   */
  1887. X/* just   Justification of string relative to reference point         */
  1888. X/*         just = 0.0 => left hand edge of string is at reference     */
  1889. X/*         just = 1.0 => right hand edge of string is at reference    */
  1890. X/*         just = 0.5 => centre of string is at reference             */
  1891. X
  1892. X#include "plplot.h"
  1893. X
  1894. Xvoid plmtex(side,disp,pos,just,text)
  1895. Xchar side[], text[];
  1896. Xfloat disp, pos, just;
  1897. X{
  1898. X      int clpxmi, clpxma, clpymi, clpyma;
  1899. X      int sppxmi, sppxma, sppymi, sppyma;
  1900. X      int vert, refx, refy;
  1901. X      float shift, xform[4];
  1902. X      float vpdxmi, vpdxma, vpdymi, vpdyma;
  1903. X      float chrdef, chrht;
  1904. X      float mpxscl, mpxoff, mpyscl, mpyoff;
  1905. X
  1906. X      int level;
  1907. X      glev(&level);
  1908. X      if (level < 2) fatal("Please set up viewport before calling PLMTEX.");
  1909. X      
  1910. X      /* Open clip limits to subpage limits */
  1911. X
  1912. X      gclp(&clpxmi,&clpxma,&clpymi,&clpyma);
  1913. X      gspp(&sppxmi,&sppxma,&sppymi,&sppyma);
  1914. X      sclp(sppxmi,sppxma,sppymi,sppyma);
  1915. X
  1916. X      gvpd(&vpdxmi,&vpdxma,&vpdymi,&vpdyma);
  1917. X      gmp(&mpxscl,&mpxoff,&mpyscl,&mpyoff);
  1918. X      gchr(&chrdef,&chrht);
  1919. X
  1920. X      shift = 0.0;
  1921. X      if (just!=0.0) shift = just * plstrl(text);
  1922. X
  1923. X      if (strpos(side,'B')!=-1 || strpos(side,'b')!=-1) {
  1924. X        vert = 0;
  1925. X        refx = dcpcx(vpdxmi + (vpdxma-vpdxmi) * pos) - shift*mpxscl;
  1926. X        refy = mmpcy(dcmmy(vpdymi) - disp * chrht);
  1927. X      }
  1928. X      else if (strpos(side,'T')!=-1 || strpos(side,'t')!=-1) {
  1929. X        vert = 0;
  1930. X        refx = dcpcx(vpdxmi + (vpdxma-vpdxmi) * pos) - shift*mpxscl;
  1931. X        refy = mmpcy(dcmmy(vpdyma) + disp * chrht);
  1932. X      }
  1933. X      else if (stindex(side,"LV")!=-1 || stindex(side,"lv")!=-1) {   
  1934. X        vert = 0;
  1935. X        refy = dcpcy(vpdymi + (vpdyma-vpdymi) * pos);
  1936. X        refx = mmpcx(dcmmx(vpdxmi) - disp * chrht - shift);
  1937. X      }
  1938. X      else if (stindex(side,"RV")!=-1 || stindex(side,"rv")!=-1) {
  1939. X        vert = 0;
  1940. X        refy = dcpcy(vpdymi + (vpdyma-vpdymi) * pos);
  1941. X        refx = mmpcx(dcmmx(vpdxma) + disp * chrht - shift);
  1942. X      }
  1943. X      else if (strpos(side,'L')!=-1 || strpos(side,'l')!=-1) {   
  1944. X        vert = 1;
  1945. X        refy = dcpcy(vpdymi + (vpdyma-vpdymi) * pos) - shift*mpyscl;
  1946. X        refx = mmpcx(dcmmx(vpdxmi) - disp * chrht);
  1947. X      }
  1948. X      else if (strpos(side,'R')!=-1 || strpos(side,'r')!=-1) {
  1949. X        vert = 1;
  1950. X        refy = dcpcy(vpdymi + (vpdyma-vpdymi) * pos) - shift*mpyscl;
  1951. X        refx = mmpcx(dcmmx(vpdxma) + disp * chrht);
  1952. X      }
  1953. X      else {
  1954. X        sclp(clpxmi,clpxma,clpymi,clpyma);
  1955. X        return;
  1956. X      }
  1957. X
  1958. X      if (vert != 0) {
  1959. X        xform[0] = 0.0;
  1960. X        xform[1] = -1.0;
  1961. X        xform[2] = 1.0;
  1962. X        xform[3] = 0.0;
  1963. X      }
  1964. X      else {
  1965. X        xform[0] = 1.0;
  1966. X        xform[1] = 0.0;
  1967. X        xform[2] = 0.0;
  1968. X        xform[3] = 1.0;
  1969. X      }
  1970. X      plstr(0,xform,refx,refy,text);
  1971. X      sclp(clpxmi,clpxma,clpymi,clpyma);
  1972. X}
  1973. SHAR_EOF
  1974. echo "extracting plnxtv.c"
  1975. sed 's/^X//' << \SHAR_EOF > plnxtv.c
  1976. X/* Draws the next view of a 3-d plot. The physical coordinates of */
  1977. X/* the points for the next view are placed in the n points of arrays  */
  1978. X/* u and v. The silhouette found so far is stored in the heap as a */
  1979. X/* set of m peak points. */
  1980. X
  1981. X/* Define the heap size.  This can be increased if necessary.  Someday */
  1982. X/* I hope to just allocate a heap space of minimum required size.      */
  1983. X#define  heaps    4000
  1984. X
  1985. X#include <stdio.h>
  1986. X#include <stdlib.h>
  1987. X#include "plplot.h"
  1988. X#include "declare.h"
  1989. X
  1990. Xstatic int m, x, y;
  1991. X
  1992. Xvoid plnxtv(u,v,n,init)
  1993. Xint u[], v[], n, init;
  1994. X{
  1995. X      int xx;
  1996. X      int i, j, first;
  1997. X      int sx1, sx2, sy1, sy2;
  1998. X      int su1, su2, sv1, sv2;
  1999. X      int cx, cy, px, py;
  2000. X      int seg, ptold, lstold, pthi, pnewhi, newhi, change, ochange;
  2001. X      
  2002. X      first = 1;
  2003. X      pnewhi = 0;
  2004. X      
  2005. X      /* For the initial set of points, just display them and store them as */
  2006. X      /* the peak points. */
  2007. X
  2008. X      if (init == 1) {
  2009. X         if( heap3 == NULL)  /* heap not yet allocated so ... */
  2010. X            if(( heap3 = (int *)malloc(heaps*sizeof(int))) == NULL)
  2011. X               fatal("Not enough heap space in PLNXTV.");
  2012. X         y = heaps - n;
  2013. X         x = y - n;
  2014. X         movphy(u[0],v[0]);
  2015. X         heap3[x] = u[0];
  2016. X         heap3[y] = v[0];
  2017. X         for (i=1; i<n; i++){
  2018. X           draphy(u[i],v[i]);
  2019. X           heap3[x+i] = u[i];
  2020. X           heap3[y+i] = v[i];
  2021. X         }
  2022. X         m = n;
  2023. X         return;
  2024. X      }
  2025. X
  2026. X      /* Otherwise, we need to consider hidden-line removal problem. We scan */
  2027. X      /* over the points in both the old (i.e. heap3[x...] and heap3[y...]) and */
  2028. X      /* new (i.e. u[] and v[]) arrays in order of increasing x coordinate. */
  2029. X      /* At each stage, we find the line segment in the other array (if one */
  2030. X      /* exists) that straddles the x coordinate of the point. We */
  2031. X      /* have to determine if the point lies above or below the line segment, */
  2032. X      /* and to check if the below/above status has changed since the last */
  2033. X      /* point. */
  2034. X
  2035. X      /* If init = 2 we do not update the view, this is useful for drawing */
  2036. X      /* lines on the graph after we are done plotting points.  Hidden line */
  2037. X      /* removal is still done, but the view is not updated. */
  2038. X      xx = 0;
  2039. X      i = 0;
  2040. X      j = 0;
  2041. X
  2042. X      /* (heap3[x+i], heap3[y+i]) is the i'th point in the old array */
  2043. X      /* (u[j], v[j])           is the j'th point in the new array */
  2044. X
  2045. X      while (i < m || j < n) {
  2046. X
  2047. X        /* The coordinates of the point under consideration are (px,py). */
  2048. X        /* The line segment joins (sx1,sy1) to (sx2,sy2). */
  2049. X
  2050. X        /* "ptold" is true if the point lies in the old array. We set it */
  2051. X        /*  by comparing the x coordinates of the i'th old point */
  2052. X        /*  and the j'th new point, being careful if we have fallen past */
  2053. X        /*  the edges. Having found the point, load up the point and */
  2054. X        /*  segment coordinates appropriately. */
  2055. X        ptold = ((heap3[x+i] < u[j] && i<m) || j>= n);
  2056. X        if (ptold) {
  2057. X          px = heap3[x+i];
  2058. X          py = heap3[y+i];
  2059. X          seg = j>0 && j<n;
  2060. X          if (seg) {
  2061. X            sx1 = u[j-1];
  2062. X            sy1 = v[j-1];
  2063. X            sx2 = u[j];
  2064. X            sy2 = v[j];
  2065. X          }
  2066. X        }
  2067. X        else {
  2068. X          px = u[j];
  2069. X          py = v[j];
  2070. X          seg = i>0 && i<m;
  2071. X          if (seg) {
  2072. X            sx1 = heap3[x+i-1];
  2073. X            sy1 = heap3[y+i-1];
  2074. X            sx2 = heap3[x+i];
  2075. X            sy2 = heap3[y+i];
  2076. X          }
  2077. X        }
  2078. X
  2079. X        /* Now determine if the point is higher than the segment, using the */
  2080. X        /* logical function "above". We also need to know if it is */
  2081. X        /* the old view or the new view that is higher. "newhi" is set true */
  2082. X        /* if the new view is higher than the old */
  2083. X
  2084. X        if(seg)
  2085. X            pthi = plabv(px,py,sx1,sy1,sx2,sy2);
  2086. X        else
  2087. X            pthi = 1;
  2088. X
  2089. X        newhi = (ptold && !pthi) || (!ptold && pthi);
  2090. X        change = (newhi && !pnewhi) || (!newhi && pnewhi);
  2091. X
  2092. X        /* There is a new intersection point to put in the peak array if the */
  2093. X        /* state of "newhi" changes */
  2094. X
  2095. X        if (first) {
  2096. X          movphy(px,py);
  2097. X          first = 0;
  2098. X          lstold = ptold;
  2099. X          if (init != 2) {
  2100. X            heap3[xx] = px;
  2101. X            heap3[xx+1] = py;
  2102. X            xx = xx + 2;
  2103. X          }
  2104. X          pthi = 0;
  2105. X          ochange = 0;
  2106. X        }
  2107. X        else if (change) {
  2108. X          /* Take care of special cases at end of arrays.  If init is 2 the */
  2109. X          /* endpoints are not connected to the old view. */
  2110. X          if (init==2 && ((!ptold && j==0)||(ptold && i==0))) {
  2111. X            movphy(px,py);
  2112. X            lstold = ptold;
  2113. X            pthi = 0;
  2114. X            ochange = 0;
  2115. X          }
  2116. X          else if (init==2 && ((!ptold && i>=m)||(ptold && j>=n))) {
  2117. X            movphy(px,py);
  2118. X            lstold = ptold;
  2119. X            pthi = 0;
  2120. X            ochange = 0;
  2121. X          }
  2122. X          /* If init is not 2 then we do want to connect the current line */
  2123. X          /* with the previous view at the endpoints.  */
  2124. X          /* Also find intersection point with old view. */
  2125. X          else  {
  2126. X            if (i == 0) {
  2127. X              sx1 = heap3[x];
  2128. X              sy1 = -1;
  2129. X              sx2 = heap3[x];
  2130. X              sy2 = heap3[y];
  2131. X            }
  2132. X            else if (i >= m) {
  2133. X              sx1 = heap3[x+m-1];
  2134. X              sy1 = heap3[y+m-1];
  2135. X              sx2 = heap3[x+m-1];
  2136. X              sy2 = -1;
  2137. X            }
  2138. X            else {
  2139. X              sx1 = heap3[x+i-1];
  2140. X              sy1 = heap3[y+i-1];
  2141. X              sx2 = heap3[x+i];
  2142. X              sy2 = heap3[y+i];
  2143. X            }
  2144. X
  2145. X            if (j == 0) {
  2146. X              su1 = u[0];
  2147. X              sv1 = -1;
  2148. X              su2 = u[0];
  2149. X              sv2 = v[0];
  2150. X            }
  2151. X            else if (j >= n) {
  2152. X              su1 = u[n-1];
  2153. X              sv1 = v[n-1];
  2154. X              su2 = u[n];
  2155. X              sv2 = -1;
  2156. X            }
  2157. X            else  {
  2158. X              su1 = u[j-1];
  2159. X              sv1 = v[j-1];
  2160. X              su2 = u[j];
  2161. X              sv2 = v[j];
  2162. X            }
  2163. X
  2164. X            /* Determine the intersection */
  2165. X            pl3cut(sx1,sy1,sx2,sy2,su1,sv1,su2,sv2,&cx,&cy);
  2166. X            if (cx == px && cy == py)  {
  2167. X              if (lstold && !ochange)
  2168. X                movphy(px,py);
  2169. X              else 
  2170. X                draphy(px,py); 
  2171. X
  2172. X              if (init != 2) {
  2173. X                heap3[xx] = px;
  2174. X                heap3[xx+1] = py;
  2175. X                xx = xx+2;
  2176. X              }
  2177. X              lstold = 1;
  2178. X              pthi = 0;
  2179. X            }
  2180. X            else {
  2181. X              if (lstold && !ochange)
  2182. X                 movphy(cx,cy);
  2183. X              else
  2184. X                 draphy(cx,cy);
  2185. X
  2186. X              lstold = 1;
  2187. X              if (init != 2) {
  2188. X                heap3[xx] = cx;
  2189. X                heap3[xx+1] = cy;
  2190. X                xx = xx+2;
  2191. X              }
  2192. X            }
  2193. X            ochange =1;
  2194. X          }
  2195. X        }
  2196. X
  2197. X        /* If point is high then draw plot to point and update view. */
  2198. X        if (pthi) {
  2199. X          if (lstold && ptold)
  2200. X            movphy(px,py);
  2201. X          else 
  2202. X            draphy(px,py); 
  2203. X
  2204. X          if (init != 2) {
  2205. X            heap3[xx] = px;
  2206. X            heap3[xx+1] = py;
  2207. X            xx = xx+2;
  2208. X          }
  2209. X          lstold = ptold;
  2210. X          ochange = 0;
  2211. X        }
  2212. X
  2213. X        pnewhi = newhi;
  2214. X
  2215. X        if (ptold)
  2216. X          i = i+1;
  2217. X        else
  2218. X          j = j+1;
  2219. X
  2220. X        if (xx>=x) fatal("Heap overflow in plnxtv.");
  2221. X      }
  2222. X
  2223. X      /* Transfer the peak points to the RHS of the heap */
  2224. X
  2225. X      if(init != 2) {
  2226. X        m = xx/2;
  2227. X        xx = 0;
  2228. X        y = heaps - m;
  2229. X        x = y - m;
  2230. X        for(i=0; i<m; i++) {
  2231. X          heap3[x+i] = heap3[xx];
  2232. X          heap3[y+i] = heap3[xx+1];
  2233. X          xx = xx+2;
  2234. X        }
  2235. X      }
  2236. X}
  2237. X
  2238. SHAR_EOF
  2239. echo "End of archive 6 (of 7)"
  2240. # if you want to concatenate archives, remove anything after this line
  2241. exit
  2242.